<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
</html>
<script>
    function ajax(time){
        return new Promise((resolve,reject)=>{
            setTimeout(()=>{

                resolve()
            },5000)
        })
    }

    //Promise.all( [] ).then( ()=>{} )
    Promise.all([ajax(1000),ajax(3000),ajax(5000),ajax(2000)]).then(()=>{
        console.log('所有任务完成');
    })

  //Promise.race( [] ).then( ()=>{} )
  Promise.race([ajax(1000),ajax(3000),ajax(5000),ajax(2000)]).then(()=>{
    console.log('已经完成了一个任务，但是其他任务可能还没完成');
  })
</script>